﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using mock_ehr_lib.Model;
using mock_ehr_lib.View.MainTabs;
using Immunizations = mock_ehr_lib.Model.Immunizations;

namespace mock_ehr_lib.View
{
    public partial class Main : Form
    {
        public Main()
        {
            InitializeComponent();
            Closed += mainClosed;
            Load += load;
            btnPatientSearch.Click += patientSearch;
            MockEHRApplication.Instance.OnPatientChanged += OnPatientChanged;
        }

        void load(object sender, EventArgs e)
        {
            pnlPatientInfo.Controls.Add(new PatientInfo { Dock = DockStyle.Fill });
            tpOverview.Controls.Add(new Overview { Dock = DockStyle.Fill });
            tpProblems.Controls.Add(new Problems { Dock = DockStyle.Fill });
            tpHistory.Controls.Add(new History { Dock = DockStyle.Fill });
            tpAlerts.Controls.Add(new Alerts { Dock = DockStyle.Fill });
            tpImmunization.Controls.Add(new Immunization { Dock = DockStyle.Fill });
            tpResults.Controls.Add(new Results { Dock = DockStyle.Fill });
            tpQuality.Controls.Add(new Quality { Dock = DockStyle.Fill });
        }

        void patientSearch(object sender, EventArgs e)
        {
            var patientSearch = new PatientSearch();
            patientSearch.ShowDialog();
            if(patientSearch.SelectedPatient != null)
            {
                MockEHRApplication.Instance.CurrentPatient = patientSearch.SelectedPatient;
            }
        }

        void mainClosed(object sender, EventArgs e)
        {
            Application.Exit();
        }

        void OnPatientChanged(Patient newPatient)
        {

        }
    }
}
